<template>
  <div class="page_search search_index">
    <div class="warp">
      <div class="container">
        <div class="row">
          <div class="col-12">
            <div class="card_result_search">
              <div class="title">搜索结果</div>

              <!-- 文章搜索结果 -->
              <list_result_search
                  :list="result_article"
                  title="旅游资讯"
                  source_table="article"
              ></list_result_search>


              <list_result_search
                  v-if="$check_action('/registered_users/list', 'get')"
                  :list="result_registered_users_user_name"
                  title="注册用户用户姓名"
                  source_table="registered_users"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/registered_users/list', 'get')"
                  :list="result_registered_users_user_gender"
                  title="注册用户用户性别"
                  source_table="registered_users"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/registered_users/list', 'get')"
                  :list="result_registered_users_user_phone_number"
                  title="注册用户用户电话"
                  source_table="registered_users"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/tourist_routes/list', 'get')"
                  :list="result_tourist_routes_route_number"
                  title="旅游路线路线编号"
                  source_table="tourist_routes"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/tourist_routes/list', 'get')"
                  :list="result_tourist_routes_starting_point_of_the_route"
                  title="旅游路线路线起点"
                  source_table="tourist_routes"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/tourist_routes/list', 'get')"
                  :list="result_tourist_routes_route_endpoint"
                  title="旅游路线路线终点"
                  source_table="tourist_routes"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/tourist_routes/list', 'get')"
                  :list="result_tourist_routes_tourism_classification"
                  title="旅游路线旅游分类"
                  source_table="tourist_routes"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/booking_records/list', 'get')"
                  :list="result_booking_records_booking_number"
                  title="预订记录预订编号"
                  source_table="booking_records"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/booking_records/list', 'get')"
                  :list="result_booking_records_user_name"
                  title="预订记录用户姓名"
                  source_table="booking_records"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/booking_records/list', 'get')"
                  :list="result_booking_records_route_number"
                  title="预订记录路线编号"
                  source_table="booking_records"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/unsubscribe_record/list', 'get')"
                  :list="result_unsubscribe_record_user_name"
                  title="退订记录用户姓名"
                  source_table="unsubscribe_record"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/unsubscribe_record/list', 'get')"
                  :list="result_unsubscribe_record_booking_number"
                  title="退订记录预订编号"
                  source_table="unsubscribe_record"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/unsubscribe_record/list', 'get')"
                  :list="result_unsubscribe_record_route_number"
                  title="退订记录路线编号"
                  source_table="unsubscribe_record"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/recruitment_information/list', 'get')"
                  :list="result_recruitment_information_recruitment_company"
                  title="招聘信息招聘公司"
                  source_table="recruitment_information"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/recruitment_information/list', 'get')"
                  :list="result_recruitment_information_recruitment_positions"
                  title="招聘信息招聘职位"
                  source_table="recruitment_information"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/recruitment_information/list', 'get')"
                  :list="result_recruitment_information_describe_photos"
                  title="招聘信息描述照片"
                  source_table="recruitment_information"
              ></list_result_search>
              <list_result_search
                  v-if="$check_action('/tourism_classification/list', 'get')"
                  :list="result_tourism_classification_classification_name"
                  title="旅游分类分类名称"
                  source_table="tourism_classification"
              ></list_result_search>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import mixin from "../../mixins/page.js";
import list_result_search from "../../components/diy/list_result_search.vue";

export default {
  mixins: [mixin],
  data() {
    return {
      "query": {
        word: "",
      },
      "result_article": [],
      "result_registered_users_user_name": [],
      "result_registered_users_user_gender": [],
      "result_registered_users_user_phone_number": [],
      "result_tourist_routes_route_number": [],
      "result_tourist_routes_starting_point_of_the_route": [],
      "result_tourist_routes_route_endpoint": [],
      "result_tourist_routes_tourism_classification": [],
      "result_booking_records_booking_number": [],
      "result_booking_records_user_name": [],
      "result_booking_records_route_number": [],
      "result_unsubscribe_record_user_name": [],
      "result_unsubscribe_record_booking_number": [],
      "result_unsubscribe_record_route_number": [],
      "result_recruitment_information_recruitment_company": [],
      "result_recruitment_information_recruitment_positions": [],
      "result_recruitment_information_describe_photos": [],
      "result_tourism_classification_classification_name": [],
    };
  },
  methods: {
    /**
     * 获取文章
     */
    get_article() {
      this.$get("~/api/article/get_list?like=0", {page: 1, size: 10, title: this.query.word}, (json) => {
        if (json.result) {
          this.result_article = json.result.list;
        }
      });
    },

    /**
     * 获取user_name
     */
    get_registered_users_user_name() {
      let url = "~/api/registered_users/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "user_name": this.query.word}, (json) => {
        if (json.result) {
          var result_registered_users_user_name = json.result.list;
          result_registered_users_user_name.map(o => o.title = o['user_name'])
          this.result_registered_users_user_name = result_registered_users_user_name
        }
      });
    },
    /**
     * 获取user_gender
     */
    get_registered_users_user_gender() {
      let url = "~/api/registered_users/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "user_gender": this.query.word}, (json) => {
        if (json.result) {
          var result_registered_users_user_gender = json.result.list;
          result_registered_users_user_gender.map(o => o.title = o['user_gender'])
          this.result_registered_users_user_gender = result_registered_users_user_gender
        }
      });
    },
    /**
     * 获取user_phone_number
     */
    get_registered_users_user_phone_number() {
      let url = "~/api/registered_users/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "user_phone_number": this.query.word}, (json) => {
        if (json.result) {
          var result_registered_users_user_phone_number = json.result.list;
          result_registered_users_user_phone_number.map(o => o.title = o['user_phone_number'])
          this.result_registered_users_user_phone_number = result_registered_users_user_phone_number
        }
      });
    },
    /**
     * 获取route_number
     */
    get_tourist_routes_route_number() {
      let url = "~/api/tourist_routes/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "route_number": this.query.word}, (json) => {
        if (json.result) {
          var result_tourist_routes_route_number = json.result.list;
          result_tourist_routes_route_number.map(o => o.title = o['route_number'])
          this.result_tourist_routes_route_number = result_tourist_routes_route_number
        }
      });
    },
    /**
     * 获取starting_point_of_the_route
     */
    get_tourist_routes_starting_point_of_the_route() {
      let url = "~/api/tourist_routes/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "starting_point_of_the_route": this.query.word}, (json) => {
        if (json.result) {
          var result_tourist_routes_starting_point_of_the_route = json.result.list;
          result_tourist_routes_starting_point_of_the_route.map(o => o.title = o['starting_point_of_the_route'])
          this.result_tourist_routes_starting_point_of_the_route = result_tourist_routes_starting_point_of_the_route
        }
      });
    },
    /**
     * 获取route_endpoint
     */
    get_tourist_routes_route_endpoint() {
      let url = "~/api/tourist_routes/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "route_endpoint": this.query.word}, (json) => {
        if (json.result) {
          var result_tourist_routes_route_endpoint = json.result.list;
          result_tourist_routes_route_endpoint.map(o => o.title = o['route_endpoint'])
          this.result_tourist_routes_route_endpoint = result_tourist_routes_route_endpoint
        }
      });
    },
    /**
     * 获取tourism_classification
     */
    get_tourist_routes_tourism_classification() {
      let url = "~/api/tourist_routes/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "tourism_classification": this.query.word}, (json) => {
        if (json.result) {
          var result_tourist_routes_tourism_classification = json.result.list;
          result_tourist_routes_tourism_classification.map(o => o.title = o['tourism_classification'])
          this.result_tourist_routes_tourism_classification = result_tourist_routes_tourism_classification
        }
      });
    },
    /**
     * 获取booking_number
     */
    get_booking_records_booking_number() {
      let url = "~/api/booking_records/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "booking_number": this.query.word}, (json) => {
        if (json.result) {
          var result_booking_records_booking_number = json.result.list;
          result_booking_records_booking_number.map(o => o.title = o['booking_number'])
          this.result_booking_records_booking_number = result_booking_records_booking_number
        }
      });
    },
    /**
     * 获取user_name
     */
    get_booking_records_user_name() {
      let url = "~/api/booking_records/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "user_name": this.query.word}, (json) => {
        if (json.result) {
          var result_booking_records_user_name = json.result.list;
          result_booking_records_user_name.map(o => o.title = o['user_name'])
          this.result_booking_records_user_name = result_booking_records_user_name
        }
      });
    },
    /**
     * 获取route_number
     */
    get_booking_records_route_number() {
      let url = "~/api/booking_records/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "route_number": this.query.word}, (json) => {
        if (json.result) {
          var result_booking_records_route_number = json.result.list;
          result_booking_records_route_number.map(o => o.title = o['route_number'])
          this.result_booking_records_route_number = result_booking_records_route_number
        }
      });
    },
    /**
     * 获取user_name
     */
    get_unsubscribe_record_user_name() {
      let url = "~/api/unsubscribe_record/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "user_name": this.query.word}, (json) => {
        if (json.result) {
          var result_unsubscribe_record_user_name = json.result.list;
          result_unsubscribe_record_user_name.map(o => o.title = o['user_name'])
          this.result_unsubscribe_record_user_name = result_unsubscribe_record_user_name
        }
      });
    },
    /**
     * 获取booking_number
     */
    get_unsubscribe_record_booking_number() {
      let url = "~/api/unsubscribe_record/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "booking_number": this.query.word}, (json) => {
        if (json.result) {
          var result_unsubscribe_record_booking_number = json.result.list;
          result_unsubscribe_record_booking_number.map(o => o.title = o['booking_number'])
          this.result_unsubscribe_record_booking_number = result_unsubscribe_record_booking_number
        }
      });
    },
    /**
     * 获取route_number
     */
    get_unsubscribe_record_route_number() {
      let url = "~/api/unsubscribe_record/get_list?like=0";
      url = url + "&examine_state=已通过";
      this.$get(url, {page: 1, size: 10, "route_number": this.query.word}, (json) => {
        if (json.result) {
          var result_unsubscribe_record_route_number = json.result.list;
          result_unsubscribe_record_route_number.map(o => o.title = o['route_number'])
          this.result_unsubscribe_record_route_number = result_unsubscribe_record_route_number
        }
      });
    },
    /**
     * 获取recruitment_company
     */
    get_recruitment_information_recruitment_company() {
      let url = "~/api/recruitment_information/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "recruitment_company": this.query.word}, (json) => {
        if (json.result) {
          var result_recruitment_information_recruitment_company = json.result.list;
          result_recruitment_information_recruitment_company.map(o => o.title = o['recruitment_company'])
          this.result_recruitment_information_recruitment_company = result_recruitment_information_recruitment_company
        }
      });
    },
    /**
     * 获取recruitment_positions
     */
    get_recruitment_information_recruitment_positions() {
      let url = "~/api/recruitment_information/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "recruitment_positions": this.query.word}, (json) => {
        if (json.result) {
          var result_recruitment_information_recruitment_positions = json.result.list;
          result_recruitment_information_recruitment_positions.map(o => o.title = o['recruitment_positions'])
          this.result_recruitment_information_recruitment_positions = result_recruitment_information_recruitment_positions
        }
      });
    },
    /**
     * 获取describe_photos
     */
    get_recruitment_information_describe_photos() {
      let url = "~/api/recruitment_information/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "describe_photos": this.query.word}, (json) => {
        if (json.result) {
          var result_recruitment_information_describe_photos = json.result.list;
          result_recruitment_information_describe_photos.map(o => o.title = o['describe_photos'])
          this.result_recruitment_information_describe_photos = result_recruitment_information_describe_photos
        }
      });
    },
    /**
     * 获取classification_name
     */
    get_tourism_classification_classification_name() {
      let url = "~/api/tourism_classification/get_list?like=0";
      this.$get(url, {page: 1, size: 10, "classification_name": this.query.word}, (json) => {
        if (json.result) {
          var result_tourism_classification_classification_name = json.result.list;
          result_tourism_classification_classification_name.map(o => o.title = o['classification_name'])
          this.result_tourism_classification_classification_name = result_tourism_classification_classification_name
        }
      });
    },

  },
  components: {list_result_search},
  created() {
    this.query.word = this.$route.query.word || "";
  },
  mounted() {
    this.get_article();
    this.get_registered_users_user_name();
    this.get_registered_users_user_gender();
    this.get_registered_users_user_phone_number();
    this.get_tourist_routes_route_number();
    this.get_tourist_routes_starting_point_of_the_route();
    this.get_tourist_routes_route_endpoint();
    this.get_tourist_routes_tourism_classification();
    this.get_booking_records_booking_number();
    this.get_booking_records_user_name();
    this.get_booking_records_route_number();
    this.get_unsubscribe_record_user_name();
    this.get_unsubscribe_record_booking_number();
    this.get_unsubscribe_record_route_number();
    this.get_recruitment_information_recruitment_company();
    this.get_recruitment_information_recruitment_positions();
    this.get_recruitment_information_describe_photos();
    this.get_tourism_classification_classification_name();
  },
  watch: {
    $route() {
      $.push(this.query, this.$route.query);
      this.get_article();
      this.get_registered_users_user_name();
      this.get_registered_users_user_gender();
      this.get_registered_users_user_phone_number();
      this.get_tourist_routes_route_number();
      this.get_tourist_routes_starting_point_of_the_route();
      this.get_tourist_routes_route_endpoint();
      this.get_tourist_routes_tourism_classification();
      this.get_booking_records_booking_number();
      this.get_booking_records_user_name();
      this.get_booking_records_route_number();
      this.get_unsubscribe_record_user_name();
      this.get_unsubscribe_record_booking_number();
      this.get_unsubscribe_record_route_number();
      this.get_recruitment_information_recruitment_company();
      this.get_recruitment_information_recruitment_positions();
      this.get_recruitment_information_describe_photos();
      this.get_tourism_classification_classification_name();
    },
  },
};
</script>

<style scoped>
.card_search {
  text-align: center;
}

.card_result_search > .title {
  text-align: center;
  padding: 10px 0;
}
</style>
